﻿using Core.Entities;
using Core.IPepositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Infrastructure.Repositories
{
    public class RoleRepository : EntityRepository<Role>, IRoleRepository
    {
        private readonly BMSContext _db;
        public RoleRepository(BMSContext db) : base(db)
        {
            _db = db;
        }

        /// <summary>
        /// 根据角色得到菜单集合
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public List<Guid> GetAllMenuListByRole(Guid roleID)
        {
            var roleMenus = _db.Set<RoleMenu>().Where(t => t.RoleID == roleID).ToList();
            var menusIDs = roleMenus.Select(t => t.MenuID);
            return menusIDs.ToList();
        }
    }
}
